package edu.bupt.e1btree;

import java.util.LinkedList;
import java.util.List;

public class T03BinaryTreePostorder {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> integers = new LinkedList<Integer>();
        if (null == root) return integers;

        postorder(root, integers);

        return  integers;
    }

    private void postorder(TreeNode root, List<Integer> list){
        if (null != root.left){
            postorder(root.left,list);
        }

        if (null != root.right){
            postorder(root.right,list);
        }

        list.add(root.val);
    }
}
